//
//  ViewController+tile.swift
//  WZApp
//
//  Created by evol on 2018/7/11.
//  Copyright © 2018年 evol. All rights reserved.
//

import UIKit

extension ViewController {

    func setTileScrollView() -> Void {
        
        let viewModel = ELTileScrollViewModel()
        scrollView = ELTileScrollView(viewModel)
        view.addSubview(scrollView)
        scrollView.snp.makeConstraints { (make) in
            make.edges.equalTo(view)
        }
        
        // 页签点击
        viewModel.annotationTapCommand.subscribe(onNext:{[weak self] model in
            // 请求数据
            ELAppService.loadAnnotationInfomation(model.id!).subscribe(onNext:{
                [weak self] result in
                // 展示业态详情
                self?.showAnnotationInfoDetailView(result, model: model)
            }).disposed(by: (self?.disposeBag)!)
        }).disposed(by: disposeBag)

    }
    
    func showAnnotationInfoDetailView(_ infomation: ELAnnotationInfomation, model:ELTagModel) -> Void {
        let viewModel = ELAnnotationDetailVM(infomation)
        let detailView = ELAnnotationDetailView(viewModel)
        self.view.addSubview(detailView)
        
        viewModel.navigateCommand.subscribe(onNext:{ [weak self] result in
            print("导航去:", model.name ?? "没有name")
            self?.navigateRoute(model)
        }).disposed(by: disposeBag)
    }
    


}
